home *** CD-ROM | disk | FTP | other *** search
- ' WINDOW UPDATE DEMO
- ' ©1988 MacTutor®
- ' By Dave Kelly
-
- WINDOW OFF
- COORDINATE WINDOW
- DEF MOUSE=-1
- DIM Wptr&(3)
-
- APPLE MENU "About Updating…"
- MENU 1,0,1,"File"
- MENU 1,1,1,"Quit"
- EDIT MENU 2
- MENU 3,0,1,"Window"
- MENU 3,1,1,"Show Window 1"
- MENU 3,2,1,"Show Window 2"
- MENU 3,3,1,"Show Window 3"
- MENU 3,4,1,"Show All Windows"
-
- 'Find out monitor size just in case we need it
- CALL GETWMGRPORT(WMgrPort&)
- PortTop=PEEK WORD(WMgrPort&+8)
- PortLeft=PEEK WORD(WMgrPort&+10)
- PortBottom=PEEK WORD(WMgrPort&+12)
- PortRight=PEEK WORD(WMgrPort&+14)
-
- WINDOW#1,"Window 1",(PortLeft+4,PortTop+42)-(300,300),5
- Wptr&(1)=WINDOW(14)
- TEXT 3,12
- EDIT FIELD 1,"Read MacTutor!",(50,200)-(270,225),1
- GOSUB "Set Window 1 Update"
-
- WINDOW#2,"Window 2",(PortLeft+24,PortTop+62)-(320,320),5
- Wptr&(2)=WINDOW(14)
- 'NOW... Create the picture for the first window
- PICTURE ON
- TEXT 2,24,1
- COLOR=4
- PRINT@(3,1)"MacTutor®"
- COLOR=7
- TEXT 3,12,0
- PRINT@(6,4)"The Best in the West!"
- PRINT@(5,6)"This is the second window"
- PICTURE OFF,Pic2&
- PICTURE, Pic2&:' Draw the picture
- WINDOW PICTURE #2,Pic2&
-
- WINDOW#3,"Window 3",(PortLeft+44,PortTop+82)-(340,340),5
- Wptr&(3)=WINDOW(14)
- x1=0:x2=300:y1=0:y2=300
- ' bytes used = 6 + ((y2-y1)+1) * ((x2-x1+1)* bpp + 7) / 8)
- DIM Pic3%(58293) :' Enough space reserved for 32 bits-per-pixel (MAC II)
- 'NOW... Create the picture for the third window
- TEXT 2,24,1
- COLOR=4
- PRINT@(3,1)"MacTutor®"
- COLOR=7
- TEXT 3,12,0
- PRINT@(6,4)"The Best in the West!"
- PRINT@(5,6)"This is the third window"
- GET (x1,y1)-(x2,y2),Pic3%(1)
- PUT (0,0),Pic3%(1),0
-
-
- ON DIALOG GOSUB "DialogEvent"
- ON MENU GOSUB "MenuEvent"
- FLUSHEVENTS
- MENU ON:DIALOG ON
-
- "Loop"
- GOTO "Loop"
- MENU OFF:DIALOG OFF
-
- "DialogEvent"
- D=DIALOG(0)
- SELECT D
- CASE 3
- WINDOW DIALOG(3)
- CASE 4
- CALL HIDEWINDOW(Wptr&(DIALOG(4)))
- CASE 5,6,7
- IF DIALOG(5)=3 THEN GOSUB"Window3 Update" ELSE GOSUB "Set Window 1 Update"
- END SELECT
- RETURN
-
- "MenuEvent"
- Menunumber=MENU(0)
- Menuitem=MENU(1)
- MENU
- SELECT Menunumber
- CASE 255
- GOSUB "AppleMenu"
- CASE 1
- GOSUB "FileMenu"
- CASE 3
- GOSUB "WindowMenu"
- END SELECT
- RETURN
-
- "AppleMenu"
- WINDOW 4,"",(100,100)-(400,250),-2
- PICTURE ON
- TEXT 0,12,0,0
- PRINT @(2,2) "(ZBASIC) Window Update Demo V1.0"
- PRINT @(10,3)"by"
- PRINT @(8,4)"Dave Kelly"
- COLOR=6
- PRINT @(7,6)"©MacTutor, 1988"
- COLOR=7
- PRINT @(7,7)"ZBasic version 4.01"
- PICTURE OFF,Pic4&
- PICTURE ,Pic4&
- WINDOW PICTURE #4,Pic4&
- MOUSE ON
- DO
- mous=MOUSE(0)
- outsiderect=(MOUSE(1)<0 OR MOUSE(1)>300 OR MOUSE(2)<0 OR MOUSE(2)>150)
- IF MOUSE(1)=0 AND MOUSE(2)=0 THEN "Stop"
- UNTIL mous<>0 AND NOT (outsiderect)
- MOUSE OFF
- KILL PICTURE Pic4&:' Delete the picture from memory
- DIALOG ON
- WINDOW CLOSE 4
- DIALOG OFF
- RETURN
-
- "Window3 Update"
- ActiveWindow=WINDOW(0)
- WINDOW OUTPUT 3
- PUT (0,0),Pic3%(1),0
- WINDOW OUTPUT ActiveWindow
- RETURN
-
- "Set Window 1 Update"
- ActiveWindow=WINDOW(0)
- WINDOW OUTPUT 1
- 'NOW... Create the picture for the first window
- KILL PICTURE Pic1&
- PICTURE ON
- TEXT 2,24,1
- COLOR=4
- PRINT@(3,1)"MacTutor®"
- COLOR=7
- TEXT 3,12,0,0
- PRINT@(6,4)"The Best in the West!"
- PRINT@(5,6)"This is the first window"
- Editvariable$=EDIT$(1)
- PRINT@(5,8)"The edit field = ";Editvariable$
- PICTURE OFF,Pic1&
- PRINT@(5,8);SPC(100)
- PICTURE, Pic1&:' Draw the picture
- WINDOW OUTPUT ActiveWindow
- RETURN
-
- "FileMenu"
- IF Menuitem=1 THEN "Stop"
- RETURN
-
- "WindowMenu"
- SELECT Menuitem
- CASE 1
- CALL SHOWWINDOW(Wptr&(1)):WINDOW 1
- CASE 2
- CALL SHOWWINDOW(Wptr&(2)):WINDOW 2
- CASE 3
- CALL SHOWWINDOW(Wptr&(3)):WINDOW 3
- CASE 4
- FOR i=1 TO 3
- CALL SHOWWINDOW(Wptr&(i))
- WINDOW i
- NEXT i
- END SELECT
- RETURN
-
- "Stop"
- WINDOW PICTURE #1,0:'Don't update the first window anymore
- KILL PICTURE Pic1&:' Delete the picture from memory
- WINDOW PICTURE #2,0:'Don't update the second window anymore
- KILL PICTURE Pic2&:' Delete the picture from memory
- END
-